//
//  SEGHouseRentalAndSaleRequestManager.m
//  SEGCommunityBussiness
//
//  Created by 梁学彰 on 2019/9/20.
//

#import "SEGHouseRentalAndSaleRequestManager.h"
#import "SEGHousePageModel.h"
#import "SEGNewRentallistitemModel.h"
#import "SEGRegionListItemModel.h"
#import "SEGCarRentalListItemModel.h"



@implementation SEGHouseRentalAndSaleRequestManager
/**
 租售分页接口
 
 @param page 页码
 @param regionId 区域ID
 @param houseType 户型（1：1室   2：2室   3：3室  4：4室:  5：4室以上）
 @param rentalType 租售类型 1:整租 2:独立房间 3:合租床位 4:出售
 @param finished 接口返回
 */
- (void)requestRentalListWithPage:(NSUInteger )page regionId:(NSString *)regionId houseType:(NSString *)houseType rentalType:(NSString *)rentalType Finished:(SEGNetworkRequestCallBack)finished {
    NSMutableDictionary* dic = [NSMutableDictionary dictionary];
    if (page) {
        [dic setObject:[NSString stringWithFormat:@"%ld",page] forKey:@"pageNo"];
        [dic setObject:@"20" forKey:@"pageLimit"];
    }
    if (regionId) {
        [dic setObject:regionId forKey:@"regionId"];
    }
    if (houseType) {
        [dic setObject:houseType forKey:@"houseType"];
    }
    if (rentalType) {
        [dic setObject:rentalType forKey:@"rentalType"];
    }
    
    
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/bms-api/rental/rentalList",nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:GET URLString:urlString parameters:dic finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        
        NSString* code = [result objectForKey:@"code"];
        if (![code isKindOfClass:[NSString class]]) { //防止code为NSNull类型时崩溃
            code = @"-1";
        }
        NSString* message = [result objectForKey:@"message"];
        NSDictionary* data = [result objectForKey:@"data"];
        if ([data isKindOfClass:[NSNull class]]) { //防止data为NSNull类型时崩溃
            code = @"-1";
        }
        
        NSMutableDictionary* notifyDic = [NSMutableDictionary dictionaryWithObjectsAndKeys:message, @"message", code, @"code", nil];
        
        if ([code isEqualToString:@"0"]) { //业务处理成功,开始解析业务字段
            
            SEGNewRentallistDataModel* model = [SEGNewRentallistDataModel yy_modelWithDictionary:result[@"data"]];
            
            [notifyDic setObject:model forKey:@"data"];
            
            finished(notifyDic, nil);
            return;
        }else {
            NSError *err = [NSError errorWithDomain:errorMessage code:code.integerValue userInfo:@{NSLocalizedDescriptionKey: errorMessage}];
            finished(result, err);
            return;
        }
    }];
}

/**
 根据百度地图返回的cityCode 请求regionId
 
 @param cityCode 百度地图 cityCode
 @param finished 接口返回
 */
- (void)requestQueryRegionByCode:(NSString *)cityCode Finished:(SEGNetworkRequestCallBack)finished {
    NSMutableDictionary* dic = [NSMutableDictionary dictionary];
    if (cityCode) {
        [dic setObject:cityCode forKey:@"cityCode"];
    }
    
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/bms-api/city/queryRegionByCode",nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:GET URLString:urlString parameters:dic finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        
        NSString* code = [result objectForKey:@"code"];
        if (![code isKindOfClass:[NSString class]]) { //防止code为NSNull类型时崩溃
            code = @"-1";
        }
        NSString* message = [result objectForKey:@"message"];
        NSDictionary* data = [result objectForKey:@"data"];
        if ([data isKindOfClass:[NSNull class]]) { //防止data为NSNull类型时崩溃
            code = @"-1";
        }
        
        NSMutableDictionary* notifyDic = [NSMutableDictionary dictionaryWithObjectsAndKeys:message, @"message", code, @"code", nil];
        
        if ([code isEqualToString:@"0"]) { //业务处理成功,开始解析业务字段
            NSArray <SEGRegionListItemModel *> *regionList = [NSArray yy_modelArrayWithClass:[SEGRegionListItemModel class] json:[data valueForKey:@"regionList"]];
            [notifyDic setObject:regionList forKey:@"data"];
            finished(notifyDic, nil);
            return;
        } else {
            NSError *err = [NSError errorWithDomain:errorMessage code:code.integerValue userInfo:@{NSLocalizedDescriptionKey: errorMessage}];
            finished(result, err);
            return;
        }
    }];
}

- (void)requestMineRentalListWithFinished:(SEGNetworkRequestCallBack)finished {
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/bms-api/rental/queryMyRental",nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:GET URLString:urlString parameters:[NSDictionary new] finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        
        NSString* code = [result objectForKey:@"code"];
        if (![code isKindOfClass:[NSString class]]) { //防止code为NSNull类型时崩溃
            code = @"-1";
        }
        NSString* message = [result objectForKey:@"message"];
        NSDictionary* data = [result objectForKey:@"data"];
        if ([data isKindOfClass:[NSNull class]]) { //防止data为NSNull类型时崩溃
            code = @"-1";
        }
        
        NSMutableDictionary* notifyDic = [NSMutableDictionary dictionaryWithObjectsAndKeys:message, @"message", code, @"code", nil];
        
        if ([code isEqualToString:@"0"]) { //业务处理成功,开始解析业务字段
            SEGNewMineRentallistDataModel* model = [SEGNewMineRentallistDataModel yy_modelWithDictionary:result[@"data"]];
            [notifyDic setObject:model forKey:@"data"];
            finished(notifyDic, nil);
            return;
        } else {
            NSError *err = [NSError errorWithDomain:errorMessage code:code.integerValue userInfo:@{NSLocalizedDescriptionKey: errorMessage}];
            finished(result, err);
            return;
        }
    }];
}

- (void)requestSimilarRentalListWithRentalType:(NSString *)rentalType cityId:(NSString *)cityId finished:(SEGNetworkRequestCallBack)finished {
    NSMutableDictionary* dic = [NSMutableDictionary dictionary];
    if (rentalType) {
        [dic setObject:rentalType forKey:@"rentalType"];
    }
    
    if (cityId) {
        [dic setObject:cityId forKey:@"cityId"];
    }
    
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/bms-api/rental/querySimilarRental",nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:GET URLString:urlString parameters:dic finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        
        NSString* code = [result objectForKey:@"code"];
        if (![code isKindOfClass:[NSString class]]) { //防止code为NSNull类型时崩溃
            code = @"-1";
        }
        NSString* message = [result objectForKey:@"message"];
        NSDictionary* data = [result objectForKey:@"data"];
        if ([data isKindOfClass:[NSNull class]]) { //防止data为NSNull类型时崩溃
            code = @"-1";
        }
        
        NSMutableDictionary* notifyDic = [NSMutableDictionary dictionaryWithObjectsAndKeys:message, @"message", code, @"code", nil];
        
        if ([code isEqualToString:@"0"]) { //业务处理成功,开始解析业务字段
            NSArray <SEGNewRentallistitemModel *> *regionList = [NSArray yy_modelArrayWithClass:[SEGNewRentallistitemModel class] json:[data valueForKey:@"rentalList"]];
            [notifyDic setObject:regionList forKey:@"data"];
            finished(notifyDic, nil);
            return;
        } else {
            NSError *err = [NSError errorWithDomain:errorMessage code:code.integerValue userInfo:@{NSLocalizedDescriptionKey: errorMessage}];
            finished(result, err);
            return;
        }
    }];
}

- (void)requestDeleteMineHouseWithRentalId:(NSString *)rentalId finished:(SEGNetworkRequestCallBack)finished {
    NSMutableDictionary* dic = [NSMutableDictionary dictionary];
    if (rentalId) {
        [dic setObject:rentalId forKey:@"rentalId"];
    }
    
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/bms-api/rental/delete",nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:POST URLString:urlString parameters:dic finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        
        NSString* code = [result objectForKey:@"code"];
        if (![code isKindOfClass:[NSString class]]) { //防止code为NSNull类型时崩溃
            code = @"-1";
        }
        NSString* message = [result objectForKey:@"message"];
        NSDictionary* data = [result objectForKey:@"data"];
        if ([data isKindOfClass:[NSNull class]]) { //防止data为NSNull类型时崩溃
            code = @"-1";
        }
        
        NSMutableDictionary* notifyDic = [NSMutableDictionary dictionaryWithObjectsAndKeys:message, @"message", code, @"code", nil];
        
        if ([code isEqualToString:@"0"]) { //业务处理成功,开始解析业务字段
            finished(notifyDic, nil);
            return;
        } else {
            NSError *err = [NSError errorWithDomain:errorMessage code:code.integerValue userInfo:@{NSLocalizedDescriptionKey: errorMessage}];
            finished(result, err);
            return;
        }
    }];
}

- (void)requestOffLineMineHouseWithRentalId:(NSString *)rentalId releaseType:(NSString *)releaseType finished:(SEGNetworkRequestCallBack)finished {
    NSMutableDictionary* dic = [NSMutableDictionary dictionary];
    if (rentalId) {
        [dic setObject:rentalId forKey:@"rentalId"];
    }
    if (releaseType) {
        [dic setObject:releaseType forKey:@"releaseType"];
    }
    
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/bms-api/rental/offline",nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:POST URLString:urlString parameters:dic finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        
        NSString* code = [result objectForKey:@"code"];
        if (![code isKindOfClass:[NSString class]]) { //防止code为NSNull类型时崩溃
            code = @"-1";
        }
        NSString* message = [result objectForKey:@"message"];
        NSDictionary* data = [result objectForKey:@"data"];
        if ([data isKindOfClass:[NSNull class]]) { //防止data为NSNull类型时崩溃
            code = @"-1";
        }
        
        NSMutableDictionary* notifyDic = [NSMutableDictionary dictionaryWithObjectsAndKeys:message, @"message", code, @"code", nil];
        
        if ([code isEqualToString:@"0"]) { //业务处理成功,开始解析业务字段
            finished(notifyDic, nil);
            return;
        } else {
            NSError *err = [NSError errorWithDomain:errorMessage code:code.integerValue userInfo:@{NSLocalizedDescriptionKey: errorMessage}];
            finished(result, err);
            return;
        }
    }];
}

- (void)requestShineMineHouseWithRentalId:(NSString *)rentalId  finished:(SEGNetworkRequestCallBack)finished {
    NSMutableDictionary* dic = [NSMutableDictionary dictionary];
    if (rentalId) {
        [dic setObject:rentalId forKey:@"rentalId"];
    }
    
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/bms-api/rental/shine",nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:POST URLString:urlString parameters:dic finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        
        NSString* code = [result objectForKey:@"code"];
        if (![code isKindOfClass:[NSString class]]) { //防止code为NSNull类型时崩溃
            code = @"-1";
        }
        NSString* message = [result objectForKey:@"message"];
        NSDictionary* data = [result objectForKey:@"data"];
        if ([data isKindOfClass:[NSNull class]]) { //防止data为NSNull类型时崩溃
            code = @"-1";
        }
        
        NSMutableDictionary* notifyDic = [NSMutableDictionary dictionaryWithObjectsAndKeys:message, @"message", code, @"code", nil];
        
        if ([code isEqualToString:@"0"]) { //业务处理成功,开始解析业务字段
            finished(notifyDic, nil);
            return;
        } else {
            NSError *err = [NSError errorWithDomain:errorMessage code:code.integerValue userInfo:@{NSLocalizedDescriptionKey: errorMessage}];
            finished(result, err);
            return;
        }
    }];
}



///  发布帮找接口
/// @param contactName 联系人姓名
/// @param contactTel 联系人电话
/// @param findContent 具体内容
- (void)requestHelpFindWithContactName:(NSString *)contactName contactTel:(NSString *)contactTel findContent:(NSString *)findContent finished:(SEGNetworkRequestCallBack)finished {
    NSMutableDictionary* dic = [NSMutableDictionary dictionary];
    if (contactName) {
        [dic setObject:contactName forKey:@"contactName"];
    }
    
    if (contactTel) {
        [dic setObject:contactTel forKey:@"contactTel"];
    }
    
    if (findContent) {
        [dic setObject:findContent forKey:@"findContent"];
    }
    
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/bms-api/helpFind/saveHelpFind",nil];
    [SEGHTTPBusinessManager seg_requestJSONWithMethod:POST URLString:urlString parameters:dic finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        NSString* code = [result objectForKey:@"code"];
        if (![code isKindOfClass:[NSString class]]) { //防止code为NSNull类型时崩溃
            code = @"-1";
        }
        NSString* message = [result objectForKey:@"message"];
        NSDictionary* data = [result objectForKey:@"data"];
        if ([data isKindOfClass:[NSNull class]]) { //防止data为NSNull类型时崩溃
            code = @"-1";
        }
        
        NSMutableDictionary* notifyDic = [NSMutableDictionary dictionaryWithObjectsAndKeys:message, @"message", code, @"code", nil];
        
        if ([code isEqualToString:@"0"]) { //业务处理成功,开始解析业务字段
            finished(notifyDic, nil);
            return;
        } else {
            NSError *err = [NSError errorWithDomain:errorMessage code:code.integerValue userInfo:@{NSLocalizedDescriptionKey: errorMessage}];
            finished(result, err);
            return;
        }
    }];
}

- (void)requestMineCarRentalListWithFinished:(SEGNetworkRequestCallBack)finished {
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/bms-api/parking/queryMyRental",nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:GET URLString:urlString parameters:[NSDictionary new] finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        
        NSString* code = [result objectForKey:@"code"];
        if (![code isKindOfClass:[NSString class]]) { //防止code为NSNull类型时崩溃
            code = @"-1";
        }
        NSString* message = [result objectForKey:@"message"];
        NSDictionary* data = [result objectForKey:@"data"];
        if ([data isKindOfClass:[NSNull class]]) { //防止data为NSNull类型时崩溃
            code = @"-1";
        }
        
        NSMutableDictionary* notifyDic = [NSMutableDictionary dictionaryWithObjectsAndKeys:message, @"message", code, @"code", nil];
        
        if ([code isEqualToString:@"0"]) { //业务处理成功,开始解析业务字段
            SEGMineCarRentallistDataModel* model = [SEGMineCarRentallistDataModel yy_modelWithDictionary:result[@"data"]];
            [notifyDic setObject:model forKey:@"data"];
            finished(notifyDic, nil);
            return;
        } else {
            NSError *err = [NSError errorWithDomain:errorMessage code:code.integerValue userInfo:@{NSLocalizedDescriptionKey: errorMessage}];
            finished(result, err);
            return;
        }
    }];
}


- (void)requestDeleteMineCarWithRentalId:(NSString *)rentalId finished:(SEGNetworkRequestCallBack)finished {
    NSMutableDictionary* dic = [NSMutableDictionary dictionary];
    if (rentalId) {
        [dic setObject:rentalId forKey:@"rentalId"];
    }
    
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/bms-api/parking/delete",nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:POST URLString:urlString parameters:dic finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        
        NSString* code = [result objectForKey:@"code"];
        if (![code isKindOfClass:[NSString class]]) { //防止code为NSNull类型时崩溃
            code = @"-1";
        }
        NSString* message = [result objectForKey:@"message"];
        NSDictionary* data = [result objectForKey:@"data"];
        if ([data isKindOfClass:[NSNull class]]) { //防止data为NSNull类型时崩溃
            code = @"-1";
        }
        
        NSMutableDictionary* notifyDic = [NSMutableDictionary dictionaryWithObjectsAndKeys:message, @"message", code, @"code", nil];
        
        if ([code isEqualToString:@"0"]) { //业务处理成功,开始解析业务字段
            finished(notifyDic, nil);
            return;
        } else {
            NSError *err = [NSError errorWithDomain:errorMessage code:code.integerValue userInfo:@{NSLocalizedDescriptionKey: errorMessage}];
            finished(result, err);
            return;
        }
    }];
}

- (void)requestOffLineMineCarWithRentalId:(NSString *)rentalId releaseType:(NSString *)releaseType finished:(SEGNetworkRequestCallBack)finished {
    NSMutableDictionary* dic = [NSMutableDictionary dictionary];
    if (rentalId) {
        [dic setObject:rentalId forKey:@"rentalId"];
    }
    if (releaseType) {
        [dic setObject:releaseType forKey:@"releaseType"];
    }
    
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/bms-api/parking/offline",nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:POST URLString:urlString parameters:dic finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        
        NSString* code = [result objectForKey:@"code"];
        if (![code isKindOfClass:[NSString class]]) { //防止code为NSNull类型时崩溃
            code = @"-1";
        }
        NSString* message = [result objectForKey:@"message"];
        NSDictionary* data = [result objectForKey:@"data"];
        if ([data isKindOfClass:[NSNull class]]) { //防止data为NSNull类型时崩溃
            code = @"-1";
        }
        
        NSMutableDictionary* notifyDic = [NSMutableDictionary dictionaryWithObjectsAndKeys:message, @"message", code, @"code", nil];
        
        if ([code isEqualToString:@"0"]) { //业务处理成功,开始解析业务字段
            finished(notifyDic, nil);
            return;
        } else {
            NSError *err = [NSError errorWithDomain:errorMessage code:code.integerValue userInfo:@{NSLocalizedDescriptionKey: errorMessage}];
            finished(result, err);
            return;
        }
    }];
}

- (void)requestShineMineCarWithRentalId:(NSString *)rentalId  finished:(SEGNetworkRequestCallBack)finished {
    NSMutableDictionary* dic = [NSMutableDictionary dictionary];
    if (rentalId) {
        [dic setObject:rentalId forKey:@"rentalId"];
    }
    
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/bms-api/parking/shine",nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:POST URLString:urlString parameters:dic finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        
        NSString* code = [result objectForKey:@"code"];
        if (![code isKindOfClass:[NSString class]]) { //防止code为NSNull类型时崩溃
            code = @"-1";
        }
        NSString* message = [result objectForKey:@"message"];
        NSDictionary* data = [result objectForKey:@"data"];
        if ([data isKindOfClass:[NSNull class]]) { //防止data为NSNull类型时崩溃
            code = @"-1";
        }
        
        NSMutableDictionary* notifyDic = [NSMutableDictionary dictionaryWithObjectsAndKeys:message, @"message", code, @"code", nil];
        
        if ([code isEqualToString:@"0"]) { //业务处理成功,开始解析业务字段
            finished(notifyDic, nil);
            return;
        } else {
            NSError *err = [NSError errorWithDomain:errorMessage code:code.integerValue userInfo:@{NSLocalizedDescriptionKey: errorMessage}];
            finished(result, err);
            return;
        }
    }];
}

- (void)requestRegionInfoWithCommunityId:(NSString *)communityId finished:(SEGNetworkRequestCallBack)finished {
    NSMutableDictionary* dic = [NSMutableDictionary dictionary];
    if (communityId) {
        [dic setObject:communityId forKey:@"communityId"];
    }
    
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/bms-api/parking/getRegion",nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:GET URLString:urlString parameters:dic finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        
        NSString* code = [result objectForKey:@"code"];
        if (![code isKindOfClass:[NSString class]]) { //防止code为NSNull类型时崩溃
            code = @"-1";
        }
        NSString* message = [result objectForKey:@"message"];
        NSDictionary* data = [result objectForKey:@"data"];
        if ([data isKindOfClass:[NSNull class]]) { //防止data为NSNull类型时崩溃
            code = @"-1";
        }
        
        NSMutableDictionary* notifyDic = [NSMutableDictionary dictionaryWithObjectsAndKeys:message, @"message",data, @"data", code, @"code", nil];
        
        if ([code isEqualToString:@"0"]) { //业务处理成功,开始解析业务字段
            finished(notifyDic, nil);
            return;
        } else {
            NSError *err = [NSError errorWithDomain:errorMessage code:code.integerValue userInfo:@{NSLocalizedDescriptionKey: errorMessage}];
            finished(result, err);
            return;
        }
    }];
}


- (void)requestCarRentalListWithPage:(NSUInteger )page regionId:(NSString *)regionId carRentalType:(NSString *)carRentalType Finished:(SEGNetworkRequestCallBack)finished {
    NSMutableDictionary* dic = [NSMutableDictionary dictionary];
    if (page) {
        [dic setObject:[NSString stringWithFormat:@"%ld",page] forKey:@"pageNo"];
        [dic setObject:@"20" forKey:@"pageLimit"];
    }
    if (regionId) {
        [dic setObject:regionId forKey:@"regionId"];
    }
    if (carRentalType) {
        [dic setObject:carRentalType forKey:@"rentalType"];
    }
    
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/bms-api/parking/rentalList",nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:GET URLString:urlString parameters:dic finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        
        NSString* code = [result objectForKey:@"code"];
        if (![code isKindOfClass:[NSString class]]) { //防止code为NSNull类型时崩溃
            code = @"-1";
        }
        NSString* message = [result objectForKey:@"message"];
        NSDictionary* data = [result objectForKey:@"data"];
        if ([data isKindOfClass:[NSNull class]]) { //防止data为NSNull类型时崩溃
            code = @"-1";
        }
        
        NSMutableDictionary* notifyDic = [NSMutableDictionary dictionaryWithObjectsAndKeys:message, @"message", code, @"code", nil];
        
        if ([code isEqualToString:@"0"]) { //业务处理成功,开始解析业务字段
            
            SEGCarRentalListDataModel* model = [SEGCarRentalListDataModel yy_modelWithDictionary:result[@"data"]];
            
            [notifyDic setObject:model forKey:@"data"];
            
            finished(notifyDic, nil);
            return;
        }else {
            NSError *err = [NSError errorWithDomain:errorMessage code:code.integerValue userInfo:@{NSLocalizedDescriptionKey: errorMessage}];
            finished(result, err);
            return;
        }
    }];
}




@end
